import 'package:cbec_app/components/base/base_image.dart';
import 'package:cbec_app/components/base/base_interactive.dart';
import 'package:cbec_app/components/base/base_nav_bar.dart';
import 'package:cbec_app/components/base/base_page.dart';
import 'package:cbec_app/components/common/common_style.dart';
import 'package:cbec_app/components/goods/goods_add_minus.dart';
import 'package:cbec_app/pages/my/controller/redpack_ctr.dart';
import 'package:cbec_app/routes/routes.dart';
import 'package:cbec_app/utils/Tools.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

//红包购买页面
class RedpackBuy extends StatelessWidget {
  RedpackBuy({super.key});

  final RedPackController controller   = Get.put(RedPackController());

  @override
  Widget build(BuildContext context) {
    return BasePage(
      title: "提交订单",
      iconType: IconType.back,
      children: [
        Padding(
          padding: EdgeInsets.fromLTRB(8.w, 10.w, 8.w, 0.w),
          child: Container(
            decoration: border_radis(Colors.white),
            // height: 100.h,
            child: Row(
              children: [
                Container(
                  padding: EdgeInsets.only(left: 5.w),
                  child: BaseImage(url: controller.orderInfo['mainImage'], width: 77.w, height: 77.w)
                ),
                SizedBox(width: 20.w,),
                Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    SizedBox(height: 10.w),
                    Text(controller.orderInfo['commodityName'],style: setTextStyle(14, FontWeight.w300, Tools.fromHex("#333333"))),
                    SizedBox(height: 8.w),
                    Text("有效期至2022-10-07",style: setTextStyle(12, FontWeight.w300, Tools.fromHex("#999999"))),
                    SizedBox(height: 8.w),
                    Row(
                      children: [
                        Text("部分商品有效",style: setTextStyle(12, FontWeight.w300, Tools.fromHex("#999999"))),
                        SizedBox(width: 10.w,),
                        BaseInteractive(
                          onClick: () {
                            Tools.showToast("暂不支持查看");
                          },
                          childWidget: Text("查看",style: setTextStyle(12, FontWeight.w300, Tools.fromHex("#F83F2D"))),
                        )
                      ],
                    ),
                    SizedBox(height: 8.w),
                    //这里是加减
                    Container(
                      margin: EdgeInsets.only(left: 135.w),
                      child: GoodsAddMinus(num: 1,onAdd: (goodsNum) {
                        controller.setBuyNum(goodsNum);
                      },onMinus: (goodsNum) {
                        controller.setBuyNum(goodsNum);
                      },),
                    ),
                    SizedBox(height: 10.w,)
                  ],
                )
              ],
            ),
          ),
        ),


        //这里是合计

        Container(
          padding: EdgeInsets.all(10.w),
          margin: EdgeInsets.only(top: 10.w),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.end,
            children: [
              Text("合计",style: setTextStyle(13, FontWeight.w300, Tools.fromHex("#333333"))),
              SizedBox(width: 5.w),
              Text("￥",style: setTextStyle(13, FontWeight.w500, Tools.fromHex("#F83F2D"))),
              Obx(() => Text(controller.orderInfo['totalPrice'].toString(),style: setTextStyle(18, FontWeight.w500, Tools.fromHex("#F83F2D"))))
            ],
          ),
        ),


        //最下方的提交按钮
        Positioned(
          key: GlobalKey(debugLabel: 'Positioned'),
          bottom: 1,
          child: Container(
            width: 375.w,
            padding: EdgeInsets.all(10.w),
            height: 60.h,
            color: Colors.white,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Obx(() =>Text("￥${controller.orderInfo['totalPrice'].toString()}",style: setTextStyle(15, FontWeight.w700, Tools.fromHex("#F83F2D"))),),
                solidButton("提交订单",width: 100,height: 40, () { 
                  controller.submit();
                })
              ],
            ),

        ))
      ],
    );
  }
}
